home *** CD-ROM | disk | FTP | other *** search
- Path: in1.uu.net!interaccess!usenet
- From: brianmcg@interaccess.com (Brian V. McGroarty)
- Newsgroups: comp.lang.c
- Subject: Re: operator % - compiler error
- Date: 21 Mar 1996 14:13:46 GMT
- Organization: Internet Squire
- Message-ID: <4iro6q$2e9@nntp.interaccess.com>
- References: <4ini8g$i1u@spanky.pls.ov.com>
- Reply-To: brianmcg@interaccess.com
- NNTP-Posting-Host: d222.nhe.interaccess.com
- X-Newsreader: Internet Squire 1.20
-
- This is something I've wondered about. Why isn't the mod operator defined
- for floating point math? It can be implemented easily enough via something
- like:
-
- #define MOD( base, op ) ( (base) - ( (base) / (op) ) * (op) )
-
- ..so it does have validity, however the efficiency of using the remainder
- on FPUs returning the remainder along with the result of a divide is lost
- -- a spurious subtraction and multiplication are added.
-
-
-
- glenn@ov.com wrote:
- >In article 6ul@hatathli.csulb.edu, davidcho@csulb.edu (David Cho) writes:
- >>When I try to compile, I get an erro message for the following line:
-
-
- >>x=663608941*y%pow(2,32) /*I want remainder*/
-
- >>But the error message says "illegal use of floating point". What does
- >>that mean? Isn't % used a an operator to calcuate the remainder?
-
- >You're missing the point. % needs an integer argument, and pow()
- >returns a double.
-
-
-
- ---
- Brian Valters McGroarty -- brianmcg@bix.com
- phone/fax (847) 439-7714
-
-
-
-